﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class index : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Label2.Text = DateTime.Now.ToShortDateString();
    }

    protected sqlDataBase db = new sqlDataBase();
    protected void BT_regedit_Click(object sender, EventArgs e)
    {
        Response.Redirect("zhuce.aspx");
    }
    protected void BT_logo_Click(object sender, EventArgs e)
    {
        string id = TextBox1.Text.Trim();
        string code = TextBox2.Text.Trim();
        if (id.Length == 0 || code.Length == 0)
        {
            Response.Write("<script>alert('账号密码都要填写！')</script>");
        }
        else
        {
            string sqlstring = "select count(*) from [b_user] where user_name = '"+id+"' and user_password = '"+code+"'";
            object result= db.runsql(sqlstring);
            
            if (result.ToString() != "0")
            {
                TextBox1.Text = id;
                TextBox2.Text = "********";
                Label1.Visible = false;
                TextBox2.Visible = false;
                TextBox1.Enabled = false;
                string findid = "select user_id from [b_user] where user_name = '" + id + "'";
                object realid = db.runsql(findid);

             
                Session["userid"] = realid;
                Response.Write("<script>alert('登陆成功！')</script>");
                
                
            }
            else
            {
                Response.Write("<script>alert('您尚未注册！')</script>");
                return;
            }
        }
    }
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        Response.Redirect("book.aspx");
    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        Response.Redirect("book.aspx");
    }
    protected void LinkButton2_Click(object sender, EventArgs e)
    {
        Response.Redirect("elc.aspx");
    }
    protected void LinkButton3_Click(object sender, EventArgs e)
    {
        Response.Redirect("teach.aspx");
    }
    protected void LinkButton4_Click(object sender, EventArgs e)
    {
        Response.Redirect("help.aspx");
    }
}
